<?php
/* SVN FILE: $Id: index.ctp 31 2009-10-07 13:55:17Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-10-07 13:55:17 +0000 (Wed, 07 Oct 2009) $
 * $Revision: 31 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/views/assessments/index.ctp $
 */
?>
<h4>Assigned / In Progress Assessments</h4>
<table>
<?php
  echo $html->tableHeaders(array('Submission #',
                                 'Started',
                                 'Assignment',
                                 'Action'));

  $started_asmts = array();

  foreach ($assessments as $assessment)
  {
    $assessment_id = $assessment['Assessment']['id'];
    $started_asmts[] = $assessment['Submission']['id'];

    if (empty($assessment['Assessment']['submitted']))
    {
      $started = $time->nice($assessment['Assessment']['created']);
      $action_link = $html->link('Edit',"/assessments/edit/$assessment_id");

      echo $html->tableCells(array($assessment['Submission']['id'],
                                   $started,
                                   $assessment['Assignment']['name'],
                                   $action_link));
    }
  }

  foreach ($assessmentAssignments as $assessment_assignment)
  {
    $submission_id = $assessment_assignment['Submission']['id'];
   
    if (!in_array($submission_id,$started_asmts))
    {
      $action_link = $html->link('Start',"/assessments/add/{$submission_id}");
      echo $html->tableCells(array($submission_id,
                                   '-',
                                   $assessment_assignment['Assignment']['name'],
                                   $action_link));
    }
  }    
?>
</table>

<h4>Completed assessments:</h4>
<table>
<?php
  if (count($assessments) > 0)
  {
    echo $html->tableHeaders(array('Submission #',
                                   'Submitted',
                                   'Assignment',
                                   "Author's Rating",
	                           'Action'));

    foreach ($assessments as $assessment)
    {    	
      $assessment_id = $assessment['Assessment']['id'];
    	
      if (!empty($assessment['Assessment']['submitted']))
      {
        $submitted = $time->nice($assessment['Assessment']['submitted']);
	
        if (empty($assessment['Assessment']['author_rating']))
        {
          $rating = '(Not Yet Rated)';
        }
        else
        {
	  $rating = $assessment['Assessment']['author_rating'] . ' out of 5';
        } 

        $view_link = $html->link('View',"/assessments/view/$assessment_id");

        echo $html->tableCells(array($assessment['Submission']['id'],
                                     $submitted,
                                     $assessment['Assignment']['name'],
                                     $rating,
                                     $view_link),
                               null,
                               array('class' => 'altrow'));


      }
    }
  }
  else
  {
?>
<tr><td>No completed assessments found for this course.</td></tr>
<?php
  }
?>
</table>